/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package sirafia_clases;

/**
 *
 * @author dell
 */
import java.sql.*;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;

/**
 *
 * @author dell
 *
 */
public class Conexion {

   static String  driver = null;
    static String connectString = null;
    static String user = null;
    static String password = null;
    static String base  = null;

    public static Connection conector() throws Exception {
        Connection conn = null;

        try {
            Properties conf = new Properties();

    	try {
               //load a properties file
                conf.load(Main.class.getResourceAsStream("propiedades_Sirafia.properties"));
               //get the property value and print it out
                driver= conf.getProperty("driver");
                connectString = conf.getProperty("connect");
                base = conf.getProperty("bd");
                user = conf.getProperty("user");
                password = conf.getProperty("password");
    	} catch (IOException ex) {
    		ex.printStackTrace();
        }

            Class.forName(driver);
            conn = DriverManager.getConnection(connectString+base, user, password);

        } catch (SQLException ex) {
            System.out.println("Hubo un problema al intentar conectarse con la base de datos ");

        } catch (ClassNotFoundException ex) {
            System.out.println(ex);
        } catch (Exception e) {
            System.out.print(e);

        }
        return conn;

    }
}
